<!DOCTYPE html>
<html dir="ltr" lang="cn">
<head>
    <meta charset="UTF-8" /> 
    <title>批量打印</title>
    <link href="__PUBLIC__/bootstrap/css/bootstrap.css" rel="stylesheet" media="all" />
    <script type="text/javascript" src="__PUBLIC__/plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <link href="__PUBLIC__/bootstrap/css/font-awesome.min.css" type="text/css" rel="stylesheet" />
	<script src="__PUBLIC__/js/layer/layer-min.js"></script><!-- 弹窗js 参考文档 http://layer.layui.com/-->
    <style media="print" type="text/css">.noprint{display:none}</style>
<script type="text/javascript">
	var jl_buy_list = "联鑫壹天达配货清单";
</script> 
</head>
<body>
	<div class="print-main">
	    选择单据打印机：<div id="printer">

		</div>
<div class="print-warp a4"><b style="color: red;font-size: 16px;">系统提示：拆单、合并单后一定要重新填写打印标签！</b>
        <!--标签-->
		<input type="hidden" name="printerb" value="{$store.biaoqian_print}">
        <input type="hidden" name="widthb" value="{$store.printb_w}">
        <input type="hidden" name="heightb" value="{$store.printb_h}">
        <!--单据-->
		<input type="hidden" name="printerd" value="{$store.orders_print}">
        <input type="hidden" name="widthd" value="{$store.printd_w}">
        <input type="hidden" name="heightd" value="{$store.printd_h}">
        <input type="hidden" name="print_type" value="{$store.print_type}">

<div id="printContent_mod" style="display:none;"> 
	<div class="print-content" style="width:202mm">
		<div class="print-panel mb0" style="padding:5mm 5mm 3mm 5mm; width:202mm">
			<link rel="stylesheet" type="text/css" href="/Public/js/pages_print.css?v=4243">
			<style type="text/css"> 
						.tr{text-align:right !important;}
						.buyer-goods-info .table{border-collapse: collapse;font-size:15px;font:12px/20px "微软雅黑","Microsoft Yahei","sans-serif", "Arial", "Verdana";}
						.print-panel .buyer-goods-info .table td{border:none; border:1px solid #000; text-align:center; color:#333;padding:5px;font-size: 15px; }.print-panel .buyer-goods-info .table th{border:none;padding:5px;}
						</style>
	<caption>
	<div class="buyer-goods-info" id="table">
		<table class="table" style="border:none;width:98%;">
			<thead> 
				<tr>
					<th width="100%" colspan="7" style="border:none;">
						<h2>{$shop_info.store_name}（{$store['store_name']}）销售单<span style="font-size:15px;font-weight: normal;">包装件数（jian_count）</span></h2>
					</th>
				</tr>
				<tr>
					<th colspan="2" style="border:none;text-align: left;font-size:15px;">客户电话：mobile</th>
					<th colspan="4" style="border:none;text-align: left;font-size:15px;">客户：company（biaoshi_xian）fast_text</th>
					<th colspan="1" style="border:none;text-align: left;font-size:15px;">NO：order_sn</th>
				</tr>
				<tr>
					<th colspan="3" style="border:none;text-align: left;font-size:15px;">收货地址：full_address</th>
					<th colspan="4" style="border:none;text-align:right;">当前是第：<font tdata="PageNO" format="ChineseNum" color="blue">##</font>页 / <font tdata="PageCount" format="ChineseNum" color="blue">##</font>页 </th>
				</tr>
				<tr>
					<td width="6%">序号</td>
					<td width="30%">商品名称</td>
					<td width="30%">商品规格(sku)</td>
					<td width="9%">数量</td>
					<td width="9%">单位</td>
					<td width="10%">供应价</td>
					<td width="10%">小计</td>
				</tr> 
			</thead>
			<tbody>
				<tr>
				<td colspan="7" style="display:none;height:0px;">g_list</td>
				</tr>
			</tbody> 
			<tfoot>
				<tr>
					<td colspan="7" class="tr">
						<span class="red"><b>订单总金额： ¥total_amount</b></span>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>
					</td>
				</tr>
				<tr>
					<td colspan="2" class="tr" style="border:none;">
					<div class="lie w300" style="text-align: left;">订货电话：{$store.store_phone}</div>
					</td>
					<td colspan="5" class="tr" style="border:none;">
					<div class="lie_colspan" style="text-align:right;">下单时间：add_time</div>
					</td>
				</tr>
				<tr>
					<td colspan="7" class="tr" style="border:none;">
					<div class="address-info" id="div3">
					    user_note
					</div>
					</td>
				</tr>
			</tfoot>
		</table>
	</div>
</div>
</div>
</div>

<div id="printContent_modb" style="display:none;">
            <div class="print-content">
			<style type="text/css">
				table{border-collapse: collapse;}
			    td{border-bottom:1px #000 solid}
			    .biaoqian{font-size:28px;border-bottom:2px solid #000;margin-top:10px;}
			    .print-handle .print-btn{width:120px;}
			</style>
                <div class="print-panel mb0" style="padding:1mm 3mm 1mm 1mm; width:{$store.printb_w}mm;border:none;">
                   <table style="width:{$store.printb_w}mm;">
                        <tbody>
					<tr style="border-bottom:2px dashed #000;">
					<td style="text-align:left;width:50mm;">
					<img src="" width="150px">
							<div><strong><span style="font-size:16px;">ON：order_sn</span></strong></div>
							<div class="biaoqian" style="font-size: 25px;"><strong>myfenbu_name：（biaoshi_xian）  fast_text</strong></div>
							<span style="font-size:18px;"><strong>件数</strong>：（）/jian_count 件</span>
						</td> 
						<td style="width:45mm;"><img id="erwei" style="float:left;" src="erweima" width="80%"></td>
						</tr>
                        <tr>
                            <td colspan="2"><span style="font-size:22px;"><strong style="font-size:22px;font-weight:bold;">客户：company</strong></span></td>
                        </tr>
						<tr>
                            <td colspan="2"><div style="font-size:16px;width:100%;"><b>备注：</b><b>{$store['store_name']}</b><span style="font-size:16px;">&nbsp;&nbsp;&nbsp;shijian</span></div>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
		</div>
		
		
	
	<div id="printContent">
	<div class="print-content" style="width:210mm">
	<?php
	foreach($orders as $key=>$v){
	?>
		<div class="print-panel mb0" style="padding:5mm 5mm 3mm 5mm; width:210mm;">
	<caption>
	<div class="buyer-goods-info" id="table">
		<table class="table" style="border: none;width:100%;">
			<thead>
				<tr>
					<th width="100%" colspan="7" style="border:none;">
						<h2>{$shop_info.store_name}（{$store['store_name']}）销售单<span style="font-size:15px;font-weight: normal;">包装件数（{$v.jian_count}）</span></h2>
					</th>
				</tr>
				<tr>
					<th colspan="2" style="border:none;text-align: left;font-size:15px;">客户电话：{$v.mobile}</th>
					<th colspan="4" style="border:none;text-align: left;font-size:15px;">客户：{$v.company}（{$v.biaoshi_xian}）{$v.fast_text}</th>
					<th colspan="1" style="border:none;text-align: left;font-size:15px;">NO：{$v.order_sn}</th>
				</tr>
				<tr>
					<th colspan="3" style="border:none;text-align: left;font-size:15px;">收货地址：{$v.full_address}</th>
					<th colspan="4" style="border:none;text-align:right;">当前是第：<font tdata="PageNO" format="ChineseNum" color="blue">##</font>页 / <font tdata="PageCount" format="ChineseNum" color="blue">##</font>页 </th>
				</tr>
				<tr>
						<td width="6%">序号</td>
					<td width="30%">商品名称</td>
					<td width="30%">商品规格(sku)</td>
					<td width="9%">数量</td>
					<td width="9%">单位</td>
					<td width="10%">供应价</td>
					<td width="10%">小计</td>
				</tr> 
			</thead>
			<tbody>
				<?php
				foreach($v[g_list] as $k=>$good){
				?>
				
			    <tr>
					<td>{$k+1}</td>
					<td class="p-name">{$good.goods_name} {$good.huodong}</td>
					<td>{$good.spec_key_name}({$good.sku})</td>
					<td>{$good['goods_num']}</td>
					<td>&nbsp;&nbsp;{$good['spu']}&nbsp;&nbsp;</td>
					<td>{:floatval($good['goods_kou_price'])}</td>
					<td>￥{:floatval(sanwei($good['goods_kou_total']))}</td>
				<?php
				}
				?>
				</tbody> 
			<tfoot>
					<tr>
					<td colspan="7" class="tr">
						<span class="red"><b>订单总金额： ¥{:floatval($v['total_amount'])}</b></span>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>
					</td>
				</tr>
				<tr>
							<td colspan="2" class="tr" style="border:none;">
							<div class="lie w300" style="text-align: left;">订货电话：{$store.store_phone}</div>
							</td>
							<td colspan="5" class="tr" style="border:none;">
							<div class="lie_colspan" style="text-align:right;">下单时间：{$v.add_time|date='Y-m-d H:i',###}</div>
							</td>
				</tr>
				<tr>
					<td colspan="7" class="tr" style="border:none;">
					<div class="address-info" id="div3">
					    <textarea class="print_textarea mt20" rel='{$v.order_id}' placeholder="请输入备注信息" rows="3">{$v.user_note}</textarea>
					    <p class="print-remark" title="点击重新编辑"></p>
					</div>
					</td>
				</tr>
			</tfoot>
		</table>
	</div>
</div>
			<?php
			}
			?>
</div>
</div>

	<div style="width: 400px;text-align:left;margin:auto;margin-top:10px;">
		<a href="javascript:void(0);" ectype="btnPreview"  class="btn btn-info" data-original-title="预览"><i class="fa fa-eye"> 预览订单</i></a>
		&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" ectype="btnPrint" class="btn btn-primary" data-original-title="一键打印"><i class="fa fa-print"></i>一键打印订单</a><br/><br/>
		<a href="javascript:void(0);" ectype="btnPreviewb"  class="btn btn-info" data-original-title="预览"><i class="fa fa-eye"> 预览标签</i></a>
		&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" ectype="btnPrints" class="btn btn-primary" data-original-title="一键打印"><i class="fa fa-print"></i>一键打印标签</a>
	</div>
	
<!-- 	<div style="width: 400px;text-align:left;margin:auto;margin-top:10px;">
		
		<a href="javascript:void(0);" ectype="btnPrintb" class="btn btn-primary" data-original-title="打印订单"><i class="fa fa-print"></i>打印标签</a> &nbsp;<a href="https://localhost:8443/CLodopfuncs.js" target="_blank" style="width: 120px;"><i class="iconfont icon-dayin"></i>解决打印冲突？</a><br/><br/><br/>
		
	</div> -->
	</div>
    </div>
	<input type="hidden" name="order_id" value="{$order.order_id}">
    <input type="hidden" name="order_type" value="order">
    <script type="text/javascript" src="/Public/js/kd_LodopFuncss.js?v=2.312"></script>
	<script type="text/javascript">
	window.onload = function() {
			var mybprint = $('input[name=printerd]').val();
			var arr = printerList();
			var html = '';
			html += '<select  id="printerd" >\n';
			for (var i = 0;i<arr.length;i++){
				if(arr[i] == mybprint){
					var selected = 'selected';
				}else{
					var selected = '';
				}
				html += '<option value="'+arr[i]+'" '+selected+'>'+arr[i]+'</option>';

			}
			html +='\t\t\t\t\t\t\t\t\t\t\t</select>';
			$('#printer').html(html);
			$('#printerd').on('change', function() {
				var t = this
				console.log($(t).val())
				$("input[name='printerd']").val($(t).val());
			});
		};
var user_note=[];

	$(document).on("click","*[ectype='btnPreview']",function(){
		$("#printContent .print_textarea").each(function(){
			var beizhu=$(this).val();
			user_note.push(beizhu);
		});
		var printer = $("input[name='printerd']").val();
		var print_type = $("input[name='print_type']").val();
		var width = $("input[name='widthd']").val()+'mm';
		var height = $("input[name='heightd']").val()+'mm';console.log(printer+'：订单预览,'+width+','+height);
		var print_data={$print_data};
	
		if (printer == '' || printer == null) {
			alert('没设置好打印机。');
			return false;
		}
		var html = $("#printContent_mod").html();
		var title = jl_buy_list;
		var strStyle = "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://yc.zczmer.com/Public/js/pages_print.css?v=13y3359\">";
		$("#content").html(html+strStyle);
		lodop_preview_htmls(title, html, printer,width,height,print_data,print_type);
	});
	
	$(document).on("click","*[ectype='btnPrint']",function(){
		$("#printContent .print_textarea").each(function(){
			var beizhu=$(this).val();var order_id=$(this).attr('rel');
			user_note.push(beizhu);
		}); 
		var printer = $("input[name='printerd']").val();
		var widths = $("input[name='widthd']").val()+'mm';
		var heights = $("input[name='heightd']").val()+'mm';
		var print_data={$print_data};
		var print_type = $("input[name='print_type']").val();
		if (printer == '' || printer == null) {
			alert('没设置好打印机。');
			return false;
		}
		$.post("/index.php/Seller/Order/order_print",
		  {
			action:"jishu",
		    order_id:"{:I('order_ids')}",
			  type:'dayin_store'
		  },
		  function(data,status){
			  if(data>0){
				   	var index=layer.confirm('已打印'+data+'次，需再次打印？', {
							  title:'温馨提示',
				    		  btn: ['确定','取消'] //按钮
				    		}, function(){
				    		    // 确定
							$.post("/index.php/Seller/Order/order_print",
							   {
							 	action:"yes",
							     order_id:"{:I('order_ids')}"
							   },
							   function(data,status){ console.log(data);});
							
							var html = $("#printContent_mod").html();
							var title = jl_buy_list;
							var strStyle = "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://yc.zczmer.com/Public/js/pages_print.css?v=13y3349\">";
							$("#content").html(html+strStyle);layer.close(index);


							lodop_print_htmls(title, html, printer,widths,heights,print_data,print_type);
							// lodop_print_htmlsb(title, $("#printContent_modb").html(), '{$store.biaoqian_print}', '100mm','80mm',{$print_datab}); //标签
				    		}, function(index){
				    			layer.close(index);
				    			return false;// 取消
				    		}
				    	);
			  }else{
				$.post("/index.php/Seller/Order/order_print",
				   {
				 	action:"yes",
				     order_id:"{:I('order_ids')}",
					   type:'dayin_store'
				   },
				   function(data,status){ console.log(data);});
				
				var html = $("#printContent_mod").html();
				var title = jl_buy_list;
				var strStyle = "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://yc.zczmer.com/Public/js/pages_print.css?v=13y3349\">";
				$("#content").html(html+strStyle);
				lodop_print_htmls(title, html, printer,widths,heights,print_data);
				// lodop_print_htmlsb(title, $("#printContent_modb").html(), '{$store.biaoqian_print}', '100mm','80mm',{$print_datab}); //标签
			  }
			  
			  });
		  
	});

$(document).on("click","*[ectype='btnPrints']",function(){
	$("#printContent .print_textarea").each(function(){
		var beizhu=$(this).val();var order_id=$(this).attr('rel');
		user_note.push(beizhu);
	});
	var printer = $("input[name='printerb']").val();
	var width = $("input[name='widthb']").val()+'mm';
	var height = $("input[name='heightb']").val()+'mm';
	var print_data={$print_datab};
	if (printer == '' || printer == null) {
		alert('没设置好打印机。');
		return false;
	}
	$.post("/index.php/Seller/Order/order_print",
			{
				action:"jishu",
				order_id:"{:I('order_ids')}",
				type:'dayin_biaoqian'
			},
			function(data,status){
				if(data>0){
					var index=layer.confirm('已打印'+data+'次，需再次打印？', {
								title:'温馨提示',
								btn: ['确定','取消'] //按钮
							}, function(){
								// 确定
								$.post("/index.php/Seller/Order/order_print",
										{
											action:"yes",
											order_id:"{:I('order_ids')}",
											type:'dayin_biaoqian'
										},
										function(data,status){ console.log(data);});

								var html = $("#printContent_modb").html();
								var title = jl_buy_list;
								// var strStyle = "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://wujin.zczmer.com//Public/js/pages_print.css?v=13y3345\">";
								// $("#content").html(html+strStyle);
							    //console.log(title);
							    //console.log(print_data);
								// lodop_print_htmls(title, html, printer,width,height,print_data);
								lodop_print_htmlsb(title, html, '{$store.biaoqian_print}', width,height,print_data); //标签
							}, function(index){
								layer.close(index);
								return false;// 取消
							}
					);
				}else{
					$.post("/index.php/Seller/Order/order_print",
							{
								action:"yes",
								order_id:"{:I('order_ids')}",
								type:'dayin_biaoqian'
							},
							function(data,status){ console.log(data);});

					var html = $("#printContent_modb").html();
					var title = jl_buy_list;
				// 	var strStyle = "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://wujin.zczmer.com//Public/js/pages_print.css?v=13y3345\">";
				// 	$("#content").html(html+strStyle);
					// lodop_print_htmls(title, html, printer,width,height,print_data);
					lodop_print_htmlsb(title,html , '{$store.biaoqian_print}', width,height,print_data); //标签
				}

			});

});

	//预览标签
        $(document).on("click", "*[ectype='btnPreviewb']", function () {
            $(".print_textarea").each(function () {
                $(this).hide(); 
                $(this).siblings(".print-remark").html($(this).val()).show();
            });
			var print_datab={$print_datab};
            var printerb = $("input[name='printerb']").val();
        	var width = $("input[name='widthb']").val()+'mm';
        	var height = $("input[name='heightb']").val()+'mm';console.log(printerb+'：标签预览,'+width+','+height);
            if (printerb == '' || printerb == null) {
                alert('没设置好打印机。');
                return false;
            }
            var html = $("#printContent_modb").html();
            var title = jl_buy_list;
            //console.log(print_datab)
            lodop_preview_htmlsb(title, html, printerb, width,height,print_datab);
        });

        $(document).on("click", "*[ectype='btnPrintb']", function () {
            $(".print_textarea").each(function () {
                $(this).hide();
                $(this).siblings(".print-remark").html($(this).val()).show();
            });
			var print_datab={$print_datab};
            var printerb = $("input[name='printerb']").val();
        	var width = $("input[name='widthb']").val()+'mm';
        	var height = $("input[name='heightb']").val()+'mm';
            if (printerb == '' || printerb == null) {
                alert('没设置好打印机。');
                return false;
            }
            var html = $("#printContent_modb").html();
            var title = jl_buy_list;
            lodop_print_htmlsb(title, html, printerb, width,height,print_datab); //lodop_print_htmlsb(title, $("#printContent_modb").html(), '{$store.biaoqian_print}', '100mm','80mm',{$print_datab});
        });
	
	</script>
</body>
</html>